//
//  MSignupViewController.m
//  Gunz
//
//  Created by Joggy on 16/5/4.
//  Copyright © 2016年 NUPT. All rights reserved.
//

#import "MSignupViewController.h"
#import "MJRefresh.h"
#import "GZConst.h"
#import "MSignupViewCell.h"

@interface MSignupViewController ()<UITableViewDelegate, UITableViewDataSource> {
    
    UITableView *table;
    
}

@end

@implementation MSignupViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self prepareForNav];
    [self prepareForLayout];
    // Do any additional setup after loading the view.
}

- (void)prepareForNav {
    [super prepareForNav];
    self.title = @"已报名的任务";
    //导航左按键
    UIImage *image = [UIImage imageNamed:@"all_back"];
    UIButton *leftBarButton = [UIButton buttonWithType:UIButtonTypeSystem];
    leftBarButton.frame = CGRectMake(0, 0, image.size.width, image.size.height);
    leftBarButton.layer.position = CGPointMake(22, 22);
    [leftBarButton setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
    [leftBarButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBarButton];
}

- (void)prepareForLayout {
    [super prepareForLayout];
    table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight - 64)];
    table.delegate = self;
    table.dataSource = self;
    table.backgroundColor = [UIColor clearColor];
    table.separatorStyle = UITableViewCellSeparatorStyleNone;
    [table registerClass:[MSignupViewCell class] forCellReuseIdentifier:@"MSignupCell"];
    table.showsVerticalScrollIndicator = false;
    table.showsHorizontalScrollIndicator = false;
    table.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
    [self.view addSubview:table];
}

- (void)headerRefresh {
    [table.mj_header endRefreshing];
}

-(void)back {
    [self.navigationController popViewControllerAnimated:true];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma 代理方法

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:true];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 6;
}

- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, MineVCInsert)];
    headView.backgroundColor = [UIColor clearColor];
    return headView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return MineVCInsert;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return MineVCCellHeight;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    MSignupViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MSignupCell"];
    return cell;
}

@end
